import React, { createContext, useReducer } from 'react'
const ColorContext = createContext({})


const UpColor = 'UpColor'

const reducer = (state, action) => {
  switch (action.type) {
    case UpColor:
      return action.color
    default:
      return state
  }
}

const Color = props => {
  const [color, dispatch] = useReducer(reducer, 'green')
  return (
    <ColorContext.Provider value={{ color, dispatch }}>
      {props.children}
    </ColorContext.Provider>
  )
}





export {
  Color,
  ColorContext,
  UpColor,
}